package Tools;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.List;
import java.util.Objects;

public class Typechange {
    public static int StringtoNum(String time)
    {
        if(Objects.equals(time, null)) return 0;
        int newtime=0;
        for(int i=0;i<time.length();i++)
            newtime=newtime*10+time.charAt(i)-'0';
        return newtime;
    }

    public static String NumtoString(int num)
    {
        String ss="";
        while(num>0)
        {
            char c= (char) ('0'+num%10);
            ss=c+ss;
            num/=10;
        }
        return ss;
    }
    public static double StringtoFloat(String ss)
    {
        if(Objects.equals(ss, null)) return 0;
        double num=0;
        int cnt=0;
        for(int i=0;i<ss.length();i++)
        {
            int c=ss.charAt(i);
            if(c=='.')
            {
                cnt=i;
                continue;
            }
            num=num*10+c-'0';
        }
        cnt=ss.length()-cnt-1;
        double ans=num;
        while(cnt>0)
        {
            ans/=10;
            cnt--;
        }
        return ans;
    }
}
